package com.lagou.threrad;

/**
 * @author: lidy
 * @date: 2021/10/8 10:12
 */
public class ThreadYieldExample {

    public static void main(String[] args) {
        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10; i++) {
                    System.out.println("线程：" + Thread.currentThread().getName() + " I：" + i);
                    if (i == 5) {
                        Thread.yield();
                    }
                }
            }
        };
        Thread t1 = new Thread(runnable, "T1");
        Thread t2 = new Thread(runnable, "T2");
        t1.start();
        t2.start();
    }
}
